package controllers

import (
	"github.com/astaxie/beego"
	"fmt"
	"wcy-xmt-api/models"
)

// 阅读
type ReadingController struct {
	beego.Controller
}

// @Title list
// @Description 订阅文章列表
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param size form int false "请求条目数"
// @Param current_page form int false "当前Page，在分页时候需要使用"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.SubscribeListResponse
// @router /subscribe/articles [post]
func (this *ReadingController) ListArticles() {
	fmt.Println("run ReadingController ListArticles")
	resStatus := &models.ResStatus{}
	response := &models.SubscribeListResponse{}
	response.Code = 0
	response.ErrMsg = ""
	response.CurPage = 1
	response.Total = 10

	arts := []*models.Article{}
	art := &models.Article{}
	art.ArticleCategory = "发现"
	art.ContentUrl = "http://mp.weixin.qq.com/s?__biz=MjM5NTAyODc2MA==&mid=405480469&idx=5&sn=1896d722e67686b306b9a427e7605952&3rd=MzA3MDU4NTYzMw==&scene=6#rd"
	art.Id = 1
	art.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	art.Time = "02月17日"
	art.Title = "爱你就是把你的朋友圈从头看到尾。"
	arts = append(arts,art)
	art = &models.Article{}
	art.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	art.Time = "1小时前"
	art.Title = "爱你就是把你的朋友圈从头看到尾。"
	art.Id = 2
	art.ArticleCategory = "文化"
	art.ContentUrl = "http://mp.weixin.qq.com/s?__biz=MjM5Njc4MDIzNw==&mid=403816102&idx=1&sn=5de33be5dd43fa6d9d8f19b751d859a2&3rd=MzA3MDU4NTYzMw==&scene=6#rd"
	arts = append(arts,art)
	response.Articles = arts

	resStatus.Code = 200
	resStatus.Data = response
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title list
// @Description 订阅公众号列表
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param size form int false "请求条目数"
// @Param current_page form int false "当前Page，在分页时候需要使用"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.GzhListResponse
// @router  /subscribe/gzhs [post]
func (this *ReadingController) ListGzhs() {
	fmt.Println("run ReadingController ListGzhs")
	resStatus := &models.ResStatus{}
	response := &models.GzhListResponse{}
	response.Code = 0
	response.ErrMsg = ""
	response.CurPage = 1
	response.Total = 10

	gzhs := []*models.GzhInfo{}
	gzh := &models.GzhInfo{}
	gzh.Id = 1
	gzh.Title = "央视新闻"
	gzh.IconUrl = "http://imgsrc.baidu.com/forum/pic/item/d833c895d143ad4b83a2e96282025aafa50f0687.jpg"
	gzh.PublishNum = 23232
	gzh.SubscribeNum = 2323
	gzhs = append(gzhs,gzh)

	gzh = &models.GzhInfo{}
	gzh.PublishNum = 23
	gzh.SubscribeNum = 231
	gzh.IconUrl = "http://imgsrc.baidu.com/forum/pic/item/d833c895d143ad4b83a2e96282025aafa50f0687.jpg"
	gzh.Title = "宁波发布"
	gzhs = append(gzhs,gzh)
	response.GzhInfos = gzhs

	resStatus.Code = 200
	resStatus.Data = response
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title list
// @Description 公众号文章列表
// @Param app form int true "App编号"
// @Param gzh_id form int true "公众号id"
// @Param size form int false "请求条目数"
// @Param current_page form int false "当前Page，在分页时候需要使用"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.SubscribeListResponse
// @router /gzh/articles [post]
func (this *ReadingController) ListGzhArticles() {
	fmt.Println("run ReadingController ListGzhArticles")
	resStatus := &models.ResStatus{}
	response := &models.SubscribeListResponse{}
	response.Code = 0
	response.ErrMsg = ""
	response.CurPage = 1
	response.Total = 10

	arts := []*models.Article{}
	art := &models.Article{}
	art.ArticleCategory = "发现"
	art.ContentUrl = "http://mp.weixin.qq.com/s?__biz=MjM5NTAyODc2MA==&mid=405480469&idx=5&sn=1896d722e67686b306b9a427e7605952&3rd=MzA3MDU4NTYzMw==&scene=6#rd"
	art.Id = 1
	art.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	art.Time = "02月17日"
	art.Title = "爱你就是把你的朋友圈从头看到尾。"
	arts = append(arts,art)
	art = &models.Article{}
	art.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	art.Time = "1小时前"
	art.Title = "爱你就是把你的朋友圈从头看到尾。"
	art.Id = 2
	art.ArticleCategory = "文化"
	art.ContentUrl = "http://mp.weixin.qq.com/s?__biz=MjM5Njc4MDIzNw==&mid=403816102&idx=1&sn=5de33be5dd43fa6d9d8f19b751d859a2&3rd=MzA3MDU4NTYzMw==&scene=6#rd"
	arts = append(arts,art)
	response.Articles = arts

	resStatus.Code = 200
	resStatus.Data = response
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title ReleaseSubscribeGzh
// @Description 解除订阅公众号
// @Param token form string true "登陆成功token"
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param gzh_id form int true "公众号id"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.ReleaseSubscribeGzhResponse
// @router /gzh/release [post]
func (this *ReadingController) ReleaseSubscribeGzh() {
	fmt.Println("run ReadingController ReleaseSubscribeGzh")
	resStatus := &models.ResStatus{}
	startStatus := &models.ReleaseSubscribeGzhResponse{}
	startStatus.Code = 0
	startStatus.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title AddSubscribeGzh
// @Description 添加订阅公众号
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param token form string true "登陆成功token"
// @Param gzh_id form int true "公众号id"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.ReleaseSubscribeGzhResponse
// @router /gzh/add [post]
func (this *ReadingController) AddSubscribeGzh() {
	fmt.Println("run ReadingController ReleaseSubscribeGzh")
	resStatus := &models.ResStatus{}
	startStatus := &models.ReleaseSubscribeGzhResponse{}
	startStatus.Code = 0
	startStatus.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title list
// @Description 按类别查询公众号信息
// @Param app form int true "App编号"
// @Param gzh_type form int true "公众号类别,1咨询，2运动，3娱乐，4生活，5科技，6行业，7艺术，8教育，9发现"
// @Param size form int false "请求条目数"
// @Param current_page form int false "当前Page，在分页时候需要使用"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.SubscribeListResponse
// @router /gzhs [post]
func (this *ReadingController) ListTypeGzhs() {
	fmt.Println("run ReadingController ListTypeGzhs")
	resStatus := &models.ResStatus{}
	response := &models.GzhListResponse{}
	response.Code = 0
	response.ErrMsg = ""
	response.CurPage = 1
	response.Total = 10

	gzhs := []*models.GzhInfo{}
	gzh := &models.GzhInfo{}
	gzh.Id = 1
	gzh.Title = "央视新闻"
	gzh.IconUrl = "http://imgsrc.baidu.com/forum/pic/item/d833c895d143ad4b83a2e96282025aafa50f0687.jpg"
	gzh.PublishNum = 23232
	gzh.SubscribeNum = 2323
	gzhs = append(gzhs,gzh)

	gzh = &models.GzhInfo{}
	gzh.PublishNum = 23
	gzh.SubscribeNum = 231
	gzh.IconUrl = "http://imgsrc.baidu.com/forum/pic/item/d833c895d143ad4b83a2e96282025aafa50f0687.jpg"
	gzh.Title = "宁波发布"
	gzhs = append(gzhs,gzh)
	response.GzhInfos = gzhs

	resStatus.Code = 200
	resStatus.Data = response
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title CollectArticle
// @Description 收藏文章
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param token form string true "登陆成功token"
// @Param article_id form int true "文章id"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.CollectArticleResponse
// @router /article/collect [post]
func (this *ReadingController) CollectArticle() {
	fmt.Println("run ReadingController ReleaseSubscribeGzh")
	resStatus := &models.ResStatus{}
	startStatus := &models.CollectArticleResponse{}
	startStatus.Code = 0
	startStatus.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title CollectArticle
// @Description 取消收藏文章
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param token form string true "登陆成功token"
// @Param article_id form int true "文章id"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.CollectArticleResponse
// @router /article/cancel [post]
func (this *ReadingController) CancelArticle() {
	fmt.Println("run ReadingController CancelArticle")
	resStatus := &models.ResStatus{}
	startStatus := &models.CollectArticleResponse{}
	startStatus.Code = 0
	startStatus.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}


// @Title PraiseArticle
// @Description 文章点赞
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param token form string true "登陆成功token"
// @Param article_id form int true "文章id"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.PraiseArticleResponse
// @router /article/praise [post]
func (this *ReadingController) PraiseArticle() {
	fmt.Println("run ReadingController PraiseArticle")
	resStatus := &models.ResStatus{}
	startStatus := &models.PraiseArticleResponse{}
	startStatus.Code = 0
	startStatus.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title UnPraise
// @Description 文章取消点赞
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param token form string true "登陆成功token"
// @Param article_id form int true "文章id"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.PraiseArticleResponse
// @router /article/unpraise [post]
func (this *ReadingController) UnPraise() {
	fmt.Println("run ReadingController UnPraise")
	resStatus := &models.ResStatus{}
	startStatus := &models.PraiseInfo{}
	startStatus.Code = 0
	startStatus.ErrMsg = "";

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title CommentArticle
// @Description 发布文章评论
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param token form string true "登陆成功token"
// @Param content form string true "评论内容"
// @Param article_id form int true "文章id"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.CommentArticleResponse
// @router /article/comment [post]
func (this *ReadingController) CommentArticle() {
	fmt.Println("run ReadingController CommentArticle")
	resStatus := &models.ResStatus{}
	startStatus := &models.CommentArticleResponse{}
	startStatus.Code = 0
	startStatus.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title ListComments
// @Description 获取文章评论
// @Param app form int true "App编号"
// @Param article_id form int true "文章id"
// @Param size form int false "请求条目数"
// @Param current_page form int false "当前Page，在分页时候需要使用"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.ListCommentsResponse
// @router /article/comments [post]
func (this *ReadingController) ListComments() {
	fmt.Println("run ReadingController ListComments")
	resStatus := &models.ResStatus{}
	response := &models.ListCommentsResponse{}
	response.Code = 0
	response.ErrMsg = ""
	response.CurPage = 1
	response.Total = 10

	comms := []*models.ArticleCommentInfo{}
	comm := &models.ArticleCommentInfo{}
	comm.Content = "人说思念也是一种幸福，可我还说就怕有些人承受不了这种幸福早多次泪流满好这样子不希望发生啊！"
	comm.IconUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	comm.Id = 1
	comm.NickName = "兰斯洛特"
	comm.Time = "1 分钟前"

	comms = append(comms,comm)
	comm = &models.ArticleCommentInfo{}
	comm.Content = "人说思念也是一种幸福，可我还说就怕有些人承受不了！"
	comm.IconUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	comm.Id = 2
	comm.NickName = "黄晓明"
	comm.Time = "1 天前"

	comms = append(comms,comm)
	response.ArticleCommentInfo = comms

	resStatus.Code = 200
	resStatus.Data = response
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title ListCollectArticles
// @Description 返回收藏文章列表
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param size form int false "请求条目数"
// @Param current_page form int false "当前Page，在分页时候需要使用"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.ListCollectArticlesResponse
// @router /collect/articles [post]
func (this *ReadingController) ListCollectArticles() {
	fmt.Println("run ReadingController ListCollectArticles")
	resStatus := &models.ResStatus{}
	response := &models.ListCollectArticlesResponse{}
	response.Code = 0
	response.ErrMsg = ""
	response.CurPage = 1
	response.Total = 10

	arts := []*models.Article{}
	art := &models.Article{}
	art.ArticleCategory = "发现"
	art.ContentUrl = "http://mp.weixin.qq.com/s?__biz=MjM5NTAyODc2MA==&mid=405480469&idx=5&sn=1896d722e67686b306b9a427e7605952&3rd=MzA3MDU4NTYzMw==&scene=6#rd"
	art.Id = 1
	art.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	art.Time = "02月17日"
	art.Title = "爱你就是把你的朋友圈从头看到尾。"
	arts = append(arts,art)
	art = &models.Article{}
	art.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	art.Time = "1小时前"
	art.Title = "爱你就是把你的朋友圈从头看到尾。"
	art.Id = 2
	art.ArticleCategory = "文化"
	art.ContentUrl = "http://mp.weixin.qq.com/s?__biz=MjM5Njc4MDIzNw==&mid=403816102&idx=1&sn=5de33be5dd43fa6d9d8f19b751d859a2&3rd=MzA3MDU4NTYzMw==&scene=6#rd"
	arts = append(arts,art)
	response.Articles = arts

	resStatus.Code = 200
	resStatus.Data = response
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}


// @Title CancelArticles
// @Description 文章批量取消收藏
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param token form string true "登陆成功token"
// @Param article_ids form string true "文章ids，中间用，分割"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.CancelArticlesResponse
// @router /collect/cancels [post]
func (this *ReadingController) CancelArticles() {
	fmt.Println("run ReadingController CollectArticles")
	resStatus := &models.ResStatus{}
	startStatus := &models.CancelArticlesResponse{}
	startStatus.Code = 0
	startStatus.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}